package com.cipe.cmrs.util;



public class Util {
	
	public static boolean isNullOrEmpty(String value) {
		return value == null || "".equals(value);
	}
	
	public static boolean isNullOrEmptyTrimmed(String value) {
		return value == null || "".equals(value.trim());
	}

	public static String concate(String[] strings, String seprater) {
		String str = "";
		if(strings != null){
			for (String string : strings) {
				if(!isNullOrEmptyTrimmed(string)){
					if(!str.isEmpty()){
						str += seprater;
					}
					str += string;
				}
			}
		}
		return str;
	}
	
	public static Double parseDouble(String value) {

		if(isNullOrEmpty(value)) {
			return null;
		}

		try {
			return Double.valueOf(value);
		}
		catch (NumberFormatException e) {
		}

		return null;
	}

	public static Long parseLong(String value) {

		if(isNullOrEmpty(value)) {
			return null;
		}
		try {
			return Long.valueOf(value);
		}
		catch (NumberFormatException e) {}
		return null;
	}
	
	public static Integer parseInteger(String value) {

		if(isNullOrEmpty(value)) {
			return null;
		}
		try {
			return Integer.valueOf(value);
		}
		catch (NumberFormatException e) {}
		return null;
	}
}
